package com.itgaohe;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itgaohe.pojo.Student;
import com.itgaohe.service.StudentService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @Classname tests
 * @Description
 * @Date 2025/3/24 20:37
 * @Created by 七安.
 */
@SpringBootTest
public class tests {
    @Autowired
    private StudentService studentService;
//    全查询
    @Test
    public void test1(){
        List<Student> list = studentService.list();
        System.out.println(list);
    }
//    id查询
    @Test
    public void test2(){
        Student byId = studentService.getById(1);
        System.out.println(byId);
    }
//    增
    @Test
    public void test3(){
        Student student = new Student();
//        student.setId(null);
        student.setStudentName("王五");
        student.setAge(67);
        boolean save = studentService.save(student);
        System.out.println(save);

    }
//    删
    @Test
    public void test4(){
//        studentService
        boolean b = studentService.removeById(3);
        System.out.println(b);
    }
//    改
    @Test
    public void test5(){
        Student student = new Student();
        student.setId(2);
        student.setAge(22);
        boolean b = studentService.updateById(student);
        System.out.println(b);
    }
    @Test
    public void test6(){
        Integer pageNum=1;
        Integer pageSize=10;
        Page<Student> studentPage = new Page<>(pageNum, pageSize);
        Page<Student> page = studentService.page(studentPage);
    }
}